package ru.lukyanets.transmission.client.util;

import java.util.Base64;

/**
 * Util class for password operations
 * @author slukyanets
 */
public final class PasswordUtil {

    /**
     * Encrypts password string
     * @param password plane text
     * @return encrypted array of bytes
     */
    public static byte[] encrypt(String password) {
        // TODO add implementation
        return password != null ? Base64.getEncoder().encode(password.getBytes()) : null;
    }

    /**
     * Decrypts password from array of bytes
     * @param bytes encrypted array of bytes
     * @return plane text password
     */
    public static String decrypt(byte[] bytes) {
        // TODO add implementation
        return bytes != null ? new String(Base64.getDecoder().decode(bytes)) : "";
    }
}
